home *** CD-ROM | disk | FTP | other *** search
- Path: newcastle.ac.uk!uknet!ukc!mcsun!fuug!news.funet.fi!sunic!dkuug!diku!torbenm
- >From: torbenm@diku.dk (Torben AEgidius Mogensen)
- Newsgroups: comp.sys.acorn
- Subject: Re: fast divide
- Message-ID: <1991Oct31.153421.22641@odin.diku.dk>
- Date: 31 Oct 91 15:34:21 GMT
- References: <3351@m1.cs.man.ac.uk>
- Sender: torbenm@freke.diku.dk
- Organization: Department of Computer Science, U of Copenhagen
- Lines: 41
-
- rogersh%t3b@uk.ac.man.cs (Huw J. Rogers) writes:
-
-
- > Can people post/email the fastest 32 bit divide/modulus
- >routines they have for the ARM? ObjAsm stuff is preferred, but
- >BASIC assembler (ugh!) will do... ;-)
-
- Here is one I cooked up. It is from memory, so there might be slight
- errors. The comparisons before the first SUB ensure that no overflow
- happens on the ASL. Worst case time is 5 cycles per bit.
-
- Arguments in p,q.
- on exit, r = p div q, p = p mod q
-
- .div
- MOV r,#0
- CMP p,q
- BLT nodiv
- CMP p,q ASL #1
- BLT div0
- CMP p,q ASL #2
- BLT div1
- ... \ repeat for 3..30
- CMP p,q ASL #31
- SUBGE p,q ASL #31
- ADDGE r,#2^31
- CMP p,q ASL #30
- .div30
- SUBGE p,q ASL #30
- ADDGE r,#2^30
- CMP p,q ASL #29
- .div29
- ... \ repeat for 29..1
- .div0
- SUBGE p,q ASL #0 \ equiv. to SUBGE p,q
- ADDGE r,#2^0
- .nodiv
- MOV PC,Link
-
-
-
-
-